package T4;
import java.util.GregorianCalendar;
public class Employee {

    String name;
    GregorianCalendar em_birthday;

    public Employee(){

    }

    public Employee(String name, GregorianCalendar em_birthday) {
        super();
        this.name = name;
        this.em_birthday = em_birthday;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public GregorianCalendar getEm_birthday() {
        return em_birthday;
    }
    public void setEm_birthday(GregorianCalendar em_birthday) {
        this.em_birthday = em_birthday;
    }

}
class SalariedEmployee extends Employee{

    int salary;

    public SalariedEmployee() {
        super();
        // TODO Auto-generated constructor stub
    }

    public SalariedEmployee(String name, GregorianCalendar em_birthday) {
        super(name, em_birthday);
        // TODO Auto-generated constructor stub
    }

    public SalariedEmployee(String name, GregorianCalendar em_birthday, int salary) {
        super(name, em_birthday);
        // TODO Auto-generated constructor stub

        this.salary=salary;
    }

    public int getSalary() {
        return salary;
    }

    public void setSalary(int salary) {
        this.salary = salary;
    }



}
class HourlyEmployee extends Employee{
    int hour_wage;
    int month_work_hour;

    public float payoff_wage(int hour){
        float wage=0;

        if(hour>160){
            wage=hour*hour_wage;
        }else{
            wage=160*hour_wage+(hour-160)*hour_wage*1.5f;
        }

        return wage;
    }

}

class SalesEmployee extends Employee{

    int month_sale_value;
    float royalty_rate;
//	工资的值由不同段的提成率分别计算
//	使用if的嵌套或switch语句实现。

    public float wage(){
        float w=month_sale_value+royalty_rate;
        return w;
    }

}
class BasePlusSalesEmployee extends SalesEmployee{

    int basepay;
    public float salary(){
        float wage=super.wage()+basepay;
        return wage;
    }

}
class EmployeeTest {
    public static void main(String[] args) {
        // 创建GregorianCalendar对象表示生日
        GregorianCalendar birthday1 = new GregorianCalendar(1990, 5, 15); // 1990年6月15日
        GregorianCalendar birthday2 = new GregorianCalendar(1985, 9, 20); // 1985年10月20日
        GregorianCalendar birthday3 = new GregorianCalendar(1995, 2, 5);  // 1995年3月5日
        GregorianCalendar birthday4 = new GregorianCalendar(1988, 7, 10); // 1988年8月10日

        // 创建不同类型的员工对象
        SalariedEmployee salariedEmployee = new SalariedEmployee("张三", birthday1, 8000);

        HourlyEmployee hourlyEmployee = new HourlyEmployee();
        hourlyEmployee.setName("李四");
        hourlyEmployee.setEm_birthday(birthday2);
        hourlyEmployee.hour_wage = 50;
        hourlyEmployee.month_work_hour = 180;

        SalesEmployee salesEmployee = new SalesEmployee();
        salesEmployee.setName("王五");
        salesEmployee.setEm_birthday(birthday3);
        salesEmployee.month_sale_value = 50000;
        salesEmployee.royalty_rate = 0.05f; // 5%的提成率

        BasePlusSalesEmployee basePlusSalesEmployee = new BasePlusSalesEmployee();
        basePlusSalesEmployee.setName("赵六");
        basePlusSalesEmployee.setEm_birthday(birthday4);
        basePlusSalesEmployee.month_sale_value = 80000;
        basePlusSalesEmployee.royalty_rate = 0.04f; // 4%的提成率
        basePlusSalesEmployee.basepay = 3000;

        // 显示各类员工信息和工资计算结果
        System.out.println("=== 固定工资员工 ===");
        System.out.println("姓名: " + salariedEmployee.getName());
        System.out.println("生日: " + (salariedEmployee.getEm_birthday().get(GregorianCalendar.YEAR)) + "年" +
                (salariedEmployee.getEm_birthday().get(GregorianCalendar.MONTH) + 1) + "月" +
                salariedEmployee.getEm_birthday().get(GregorianCalendar.DAY_OF_MONTH) + "日");
        System.out.println("月薪: " + salariedEmployee.getSalary() + "元");

        System.out.println("\n=== 计时工资员工 ===");
        System.out.println("姓名: " + hourlyEmployee.getName());
        System.out.println("生日: " + (hourlyEmployee.getEm_birthday().get(GregorianCalendar.YEAR)) + "年" +
                (hourlyEmployee.getEm_birthday().get(GregorianCalendar.MONTH) + 1) + "月" +
                hourlyEmployee.getEm_birthday().get(GregorianCalendar.DAY_OF_MONTH) + "日");
        System.out.println("小时工资: " + hourlyEmployee.hour_wage + "元/小时");
        System.out.println("本月工作小时: " + hourlyEmployee.month_work_hour + "小时");
        System.out.println("本月工资: " + hourlyEmployee.payoff_wage(hourlyEmployee.month_work_hour) + "元");

        System.out.println("\n=== 销售员工 ===");
        System.out.println("姓名: " + salesEmployee.getName());
        System.out.println("生日: " + (salesEmployee.getEm_birthday().get(GregorianCalendar.YEAR)) + "年" +
                (salesEmployee.getEm_birthday().get(GregorianCalendar.MONTH) + 1) + "月" +
                salesEmployee.getEm_birthday().get(GregorianCalendar.DAY_OF_MONTH) + "日");
        System.out.println("月销售额: " + salesEmployee.month_sale_value + "元");
        System.out.println("提成率: " + (salesEmployee.royalty_rate * 100) + "%");
        System.out.println("本月工资: " + salesEmployee.wage() + "元");

        System.out.println("\n=== 底薪+销售员工 ===");
        System.out.println("姓名: " + basePlusSalesEmployee.getName());
        System.out.println("生日: " + (basePlusSalesEmployee.getEm_birthday().get(GregorianCalendar.YEAR)) + "年" +
                (basePlusSalesEmployee.getEm_birthday().get(GregorianCalendar.MONTH) + 1) + "月" +
                basePlusSalesEmployee.getEm_birthday().get(GregorianCalendar.DAY_OF_MONTH) + "日");
        System.out.println("月销售额: " + basePlusSalesEmployee.month_sale_value + "元");
        System.out.println("提成率: " + (basePlusSalesEmployee.royalty_rate * 100) + "%");
        System.out.println("底薪: " + basePlusSalesEmployee.basepay + "元");
        System.out.println("本月工资: " + basePlusSalesEmployee.salary() + "元");
    }
}